//
//  MMScrollVC.m
//  ZZLC
//
//  Created by 杨春至 on 2017/12/14.
//  Copyright © 2017年 ZhongZeng. All rights reserved.
//

#import "MMScrollVC.h"

@interface MMScrollVC ()<UIScrollViewDelegate>

@property (nonatomic,strong)UIScrollView *scrollView;

@end

@implementation MMScrollVC

- (void)viewDidLoad {
    [super viewDidLoad];
//    [self.view addSubview:self.scrollView];
    
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    if ([scrollView isKindOfClass:[UITableView class]]||[scrollView.superview isKindOfClass:[UIWebView class]]) {
        NSLog(@"%f",scrollView.contentOffset.y);
        if (scrollView.contentOffset.y<-100) {
            scrollView.scrollEnabled = NO;
            if (self.block) {
                self.block();
                scrollView.scrollEnabled = YES;
            }
        }
    }
}
- (void)viewDidLayoutSubviews{
    [_scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
}
- (UIScrollView *)scrollView{
    if(!_scrollView){
        _scrollView = [UIScrollView new];
        _scrollView.delegate = self;
        _scrollView.contentSize = self.view.frame.size;
    }
    return _scrollView;
}
//- (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView
//{
//    return [UIImage imageNamed:@"placeholderImage"];
//}
- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView
{
    NSString *text = @"暂无数据";
    
    NSDictionary *attributes = @{NSFontAttributeName: [UIFont boldSystemFontOfSize:18.0f],
                                 NSForegroundColorAttributeName: [UIColor darkGrayColor]};
    
    return [[NSAttributedString alloc] initWithString:text attributes:attributes];
}
- (NSAttributedString *)buttonTitleForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state
{
    NSDictionary *attributes = @{NSFontAttributeName: [UIFont boldSystemFontOfSize:14.0f]};
    
    return [[NSAttributedString alloc] initWithString:@"~点击此处重试" attributes:attributes];
}
- (void)emptyDataSet:(UIScrollView *)scrollView didTapButton:(UIButton *)button
{
    NSLog(@"重试");
}
- (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView{
    return YES;
}
//- (NSAttributedString *)descriptionForEmptyDataSet:(UIScrollView *)scrollView
//{
//    NSString *text = @"This allows you to share photos from your library and save photos to your camera roll.";
//
//    NSMutableParagraphStyle *paragraph = [NSMutableParagraphStyle new];
//    paragraph.lineBreakMode = NSLineBreakByWordWrapping;
//    paragraph.alignment = NSTextAlignmentCenter;
//
//    NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:14.0f],
//                                 NSForegroundColorAttributeName: [UIColor lightGrayColor],
//                                 NSParagraphStyleAttributeName: paragraph};
//
//    return [[NSAttributedString alloc] initWithString:text attributes:attributes];
//}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

@end
